<template>
	<view>
		<view style="width: 750rpx;height: 366rpx;background: linear-gradient(180deg, #1fb0ac 0%, #F5F5F5 100%);position: relative;">
			<view class="" style="padding-top: 50rpx;padding-bottom: 30rpx;">
				<view
					style="width: 92%;margin: 20rpx auto;box-sizing: border-box;padding: 30rpx;background-color: #FFFFFF;border-radius: 20rpx;">
					<view style="line-height: 80upx;color: #333333;font-size: 30upx;height: 80rpx;">
						内容描述
					</view>
					<textarea maxlength="540" placeholder="请输入内容描述(最多540字符)" v-model="content"
						style="width: 100%;height: 300rpx;line-height: 40rpx;font-size: 26rpx;" />
					<view class="upload">
						<view class="uploadimgcont">
							<view class="uploadimga" v-for="(item,index) in addImgArray_arr" :key="index">
								<view class="delete" @click="imgdelete(index)">
									<view class="deleteline">
									</view>
								</view>
								<image @click="fangda(index)" :src="item" mode="aspectFill"></image>
							</view>
							<view v-if="addImgArray_arr.length<9" class="uploadimg" @click="chooseImage">
								<image
									src="@/static/msg/add-photo.png"
									style="border-radius: 12rpx;" mode=""></image>

							</view>
						</view>
					</view>
				</view>

				<view class="maincontent">
					<!-- <view class="input">
						<text>联系人</text>
						<input style="text-align: right;" type="text"  placeholder="请输入联系人姓名" v-model="name" />
					</view> -->
					<view class="flex justify-between" style="width: 100%;height: 100rpx;line-height: 100rpx;position: relative;margin: 0 auto;border-bottom: 2upx solid #f0f0f0;">
						<text style="float: left;color: #222222;font-size: 28rpx;">是否展示我的联系方式</text>
						<u-switch v-model="gun_code" activeColor="#1fb0ac"></u-switch>
						<!-- <switch style="float: right;transform:scale(0.7)" color="#1fb0ac" :checked="gun_code==1" @change="gun_switch1Change" /> -->
					</view>
					<view class="input flex justify-between" style="position: relative;">
						<text>联系方式</text>
						<text v-if="isShowMobile">{{ isShowMobile }}</text>
						<input v-else style="text-align: right;box-sizing: border-box;" type="number" :disabled="true" placeholder="请完善个人信息联系方式"
							v-model="mobile" />
							<!-- #ifdef MP-WEIXIN -->
							<button class="shou" @getphonenumber="login1" style="background-color: #1fb0ac;color: #FFFFFF;position: absolute;top: 50%;right: 0;transform: translateY(-50%);"
							open-type="getPhoneNumber">授权手机号</button>
							<!-- #endif -->
					</view>
					<!-- <view v-if="sf_phone" class="input" style="position: relative;">
						<text>验证码</text>
						<input style="text-align: right;padding-right: 200rpx;" type="text"
							placeholder="请输入验证码" v-model="code" />
						<button @click="huoqu" :disabled="disabled" type="default"
							style="font-size: 24rpx;color: #1fb0ac;position: absolute;top: 50%;right: 0;transform: translateY(-50%);">{{btnTitle}}</button>
					</view> -->
					<view class="input justify-between" style="position: relative;">
						<text style="width: 220rpx;">所在地</text>
						<view class="flex items-center flex-end" @click="jiage" style="flex: 1;color: #666666;font-size: 28rpx;text-align: right;">
							<u-icon name="map-fill" color="#6E737E" size="16" class="pr10"></u-icon>
							<text class="fs28">
								{{label2 || '请点击选择省市'}}
							</text>
						</view>
						<!-- <input style="text-align: right;" type="text"
							placeholder="输入地址或点击选择" v-model="address" /> -->
						<!-- <image @click="address_xx"
							src="https://frozen-info.oss-cn-shanghai.aliyuncs.com/uploads/miniapp/address_rz.png"
							style="width: 60rpx;height: 60rpx;position: absolute;top: 50%;right: 0;transform: translateY(-50%);"
							mode=""></image> -->
					</view>
					<view class="input" >
						<text>发布人身份</text>
						<!-- <input style="text-align: right;" type="text"   placeholder="收货人手机号" v-model="mobile"/> -->
						<!-- <view @click="handleTap('picker1')" style="flex: 1;text-align: right;">
							{{city1 || '请选择发布人身份'}}<text class="iconfont icon-xiangyou"></text>
						</view> -->
						<view @click="fbrsf" style="flex: 1;text-align: right;" class="fs28">
							{{city1 || '请选择发布人身份'}}<text class="iconfont icon-xiangyou"></text>
						</view>
					</view>

					<view :class="['input1',xuan_cp_list.length>0?'as1':'actives1']" >
						<text>产品分类</text>
						<!-- <input style="text-align: right;" type="text"   placeholder="收货人手机号" v-model="mobile"/> -->
						<view @click="xzcpfl" style="flex: 1;text-align: right;">
							<text v-if="xuan_cp_list.length<=0" class="text-black">请选择产品分类</text>
							<text v-if="xuan_cp_list.length>0" class="text-black">已选择产品分类</text>
							<text class="iconfont icon-xiangyou"></text>
						</view>
					</view>
					<view v-if="xuan_cp_list.length>0" style="overflow: hidden;margin: 20rpx 0;" >
						<view v-for="(item,index) in xuan_cp_list" :key='index' style="float: left;line-height: 60rpx;height: 60rpx;padding: 0 30rpx;margin: 10rpx;font-size: 26rpx;color: #333333;background-color: #F3F3F3;border-radius: 30rpx;display: inline-block;">
							{{item.name || ''}}
						</view>
					</view>
					<!-- <view v-if="chanpin_list.length>0" class="input" >
						<text style="width: 100%;">历史产品分类</text>
					</view>
					<view v-if="chanpin_list.length>0" style="overflow: hidden;margin: 20rpx 0;" >
						<view @click="dianji(index)" :class="item.check?'active':'as'" v-for="(item,index) in chanpin_list" :key='index' style="float: left;line-height: 60rpx;height: 60rpx;padding: 0 30rpx;margin: 10rpx;font-size: 26rpx;border-radius: 30rpx;display: inline-block;">
							{{item.name}}
						</view>
					</view> -->
					<textarea v-if="zidingyi!=''"  :disabled='true' :maxlength='10' :value="zidingyi" placeholder="请添加自定义产品分类(最多输入10个字)" placeholder-style="color:#666666;font-size:30rpx;" style="border-radius: 10rpx;line-height: 40rpx;color: #333333;font-size: 30rpx;background-color: #F1F1F1;box-sizing: border-box;padding: 20rpx;margin: 20rpx 0;height: 80rpx;width: 100%;" />
					<!-- <view class="input" >
						<text>帖子板块</text>
						<view @click="tzbk('picker3')" style="flex: 1;text-align: right;" class="fs28">
							{{bankuai || '请选择帖子板块'}}<text class="iconfont icon-xiangyou"></text>
						</view>
					</view> -->

					<view class="input" >
						<text>帖子分类</text>
						<!-- <input style="text-align: right;" type="text"   placeholder="收货人手机号" v-model="mobile"/> -->
						<view @click="xzfl" style="flex: 1;text-align: right;" class="text-black fs28">
							{{fenlei || '请选择帖子分类'}}<text class="iconfont icon-xiangyou"></text>
						</view>
					</view>
					<view class="moren">
							<u-checkbox v-model="default1" shape="circle" :checked="default1" name="我已阅读并同意" active-color="#1FB0AC" @change="checkboxChange"></u-checkbox>
						<text @click="ismoren" class="c666 fs24 pr10">我已阅读并同意</text>
						<text @click="fbxz" style="color: #1fb0ac;">⟪发布须知⟫</text>
					</view>

				</view>
				<button  @click="queren" :disabled="fa_bu" style="width: 92%;margin: 46rpx auto 180rpx;background-color: #1fb0ac;height: 90rpx;line-height: 90rpx;color: #FFFFFF;text-align: center;border-radius: 45rpx;font-size: 30rpx;" type="default">发布</button>
			</view>
		</view>
		<lb-picker ref="picker1" v-model="city1" mode="selector" :dataset="{ name: city1 }" :list="list"
			@confirm="handleConfirm">
		</lb-picker>
		<uni-popup id="popup" ref="popup2" :type="type" :animation="true">
			<view class="" style="background-color: #FFFFFF;padding:20upx 30upx;border-radius: 20upx;width: 500rpx;">
				<view
					style="text-align: center;height: 100upx;line-height: 100upx;color: #333333;font-weight: 600;font-size: 32rpx;">
					发布须知
				</view>
				<scroll-view scroll-y="true" style="height: 400rpx;margin-bottom: 20rpx;">
					<view style="line-height: 50rpx;color: #606266;font-size: 24rpx;" v-html="rule">

					</view>
				</scroll-view>
				<view @click="guan"
					style="width: 100%;height: 80rpx;line-height: 80rpx;background-color: #1fb0ac;border-radius: 40rpx;color: #FFFFFF;font-size: 30rpx;text-align: center;">
					确定
				</view>
			</view>
		</uni-popup>
		<uni-popup id="popup" ref="popup" :type="type" :animation="true">
			<view class="" style="background-color: #FFFFFF;padding:20upx 30upx 0;border-radius: 20upx;width: 500rpx;">
				<view
					style="text-align: center;height: 100upx;line-height: 100upx;color: #333333;font-weight: 600;font-size: 32rpx;">
					提示
				</view>
				<view class="popup-content" style="text-align: center;font-size: 28upx;">请授权您的用户信息</view>
				<view class="footer">
					<button @click="quxiao"
						style="flex: 1;background-color: #f3f3f3;color: #333333;margin-right: 20rpx;font-weight: 600;"
						type="default">取消</button>
					<button @click="login" lang="zh_CN" style="flex: 1;background-color: #000000;color: #FFFFFF;"
						open-type="getUserInfo">确定</button>
					<!-- <button @click="submitLink" type="default" class="submit">确认提交</button> -->
				</view>
			</view>
		</uni-popup>
		<uni-popup id="popup" ref="popup1" :type="type" :animation="true">
			<view class="" style="background-color: #FFFFFF;padding:20upx 30upx 0;border-radius: 20upx;width: 500rpx;">
				<view
					style="text-align: center;height: 100upx;line-height: 100upx;color: #333333;font-weight: 600;font-size: 32rpx;">
					提示
				</view>
				<view class="popup-content" style="text-align: center;font-size: 28upx;">请授权您的手机号</view>
				<view class="footer">
					<button @click="quxiao1"
						style="flex: 1;background-color: #f3f3f3;color: #333333;margin-right: 20rpx;font-weight: 600;"
						type="default">取消</button>
					<button @getphonenumber="login1" style="flex: 1;background-color: #000000;color: #FFFFFF;"
						open-type="getPhoneNumber">确定</button>

				</view>
			</view>
		</uni-popup>
		<view v-if="tc_is_show"
			style="width: 100%;height: 100vh;background: rgb(0,0,0,.5);position: fixed;top: 0;left: 0;z-index: 900;">
			<view style="position: relative;height: 100%;width: 100%;">
				<view style="position: absolute;top: 10%;left: 50%;transform: translateX(-50%);">
					<image @click="bgtu_tiao" :src="tc_image"
						style="width: 600rpx;height: 800rpx;">
					</image>
					<view class="" @click="bgguan"
						style="text-align: center;width: 100%;margin-top: 50rpx;">
						<image src="../../static/guanbi.png" style="width: 60rpx;height: 60rpx;"></image>
					</view>
				</view>
			</view>
		</view>
		<lb-picker ref="picker3" v-model="bankuai" mode="selector" :dataset="{ name: bankuai }" :list="list3"
			@confirm="handleConfirm3">
		</lb-picker>
		<lb-picker ref="picker6"
		  v-model="value2"
		  mode="multiSelector"
		  :list="list1"
		  :level="2"
		  :dataset="{ name: 'label2' }"
		  @confirm="handleConfirm4">
		</lb-picker>

		<mrhardTabbar :newsNum="xiaoxi_num"></mrhardTabbar>
		<noLoginToast ref="noLoginToast"/>
		<model ref="model"/>
		<uploadImg :singleNum="false" ref="uploadImg" v-model="addImgArray_arr" permissionCameraContent="获取拍照权限是为了能够发布帖子" permissionAlbumContent="获取相册权限，是为了能够发布帖子" />
	</view>
</template>

<script>
	import isAuditIos from '@/common/isAuditIos.js'
	import areaData from '@/sub/pages/area-data-min1.js'
	import mrhardTabbar from "../../components/mrhard-tabbar.vue";
	import permision from "@/js_sdk/wa-permission/permission.js"
	import { openAppSettingPermissions,requestAndroidPermission,hideMobile } from '@/common/index.js'
	// import QQMapWX from '@/common/qqmap-wx-jssdk.min.js'

	import LbPicker from '@/components/lb-picker'
	export default {
		components: {
			LbPicker,
			mrhardTabbar
		},
		mixins: [isAuditIos],
		data() {
			return {
				tc_is_show: false,
				tc_image: '',
				value2: [],
				label2: '',
				list1: areaData,
				chat_look:'',
				background: {
					background: 'linear-gradient(180deg, #0078FF 0%, #1fb0ac 100%)'
				},
				tit: '',
				addImgArray_arr: [],
				pl_xs: 2,
				default1: true,
				content: '',
				name: '',
				mobile: '',
				address: '',
				code: '',
				longitude: '',
				latitude: '',
				city: '',
				province:'',
				area:'',
				region: '',
				city1: '个人',
				list: [],
				btnTitle: "获取验证码",
				disabled: false,
				type: 'center',
				sf_phone: false,
				did: '',
				num: '',
				rule: '',
				yemc: '',
				zpzw: '',
				szhy: '',
				zd_list: [],
				xz: 'https://frozen-info.oss-cn-shanghai.aliyuncs.com/uploads/miniapp/54.png',
				wxz: 'https://frozen-info.oss-cn-shanghai.aliyuncs.com/uploads/miniapp/53.png',
				zd_type: 0,
				zd_status: 1,
				zf_list: ['微信支付', '积分支付'],
				status:1,
				post_id:'',
				xian:false,
				fa_bu:false,
				daid:'',
				id:'',
				id_list:[],
				idfanwei_list:[],
				fenlei:'',
				chanpin:'',
				chanpin_list:[],
				xuan_cp_list:[],
				zidingyi:'',
				isShowMobile:'',
				bankuai:'',
				yuan_list3:[],
				list3:[],
				bankuai_id:'',
				degree:0,
				cishu:0,
				gun_code:false,
				zixuan_id:[],
				xiaoxi_num:'',
				zuixin:{},
				pingguo_xian:false,
				firstCome: true,
    	  uploadImgUrl: ''
			}
		},
		// onReady() {
		// 	qqmap = new QQMapWX({
		// 		// key: ‘PATBZ-EZURU-G***FU-GCBRO-LWFXC’
		// 		key: 'FOPBZ-BUOO4-5RZUS-DHXVW-EBIYJ-PDBSC'
		// 	});
		// 	// this.address_xx()
		// },
		onPullDownRefresh() {

			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1500);
		},
		onReady() {
			let token = uni.getStorageSync('token')
			if (token) {
				this.user_info()
			}
		},
		onLoad(option) {
			if(uni.getStorageSync('tan_type')!=1){
				this.tankuang()
			}
			let token = uni.getStorageSync('token')
			if (token) {
				this.shuju()
				this.cishu=this.cishu+1
				// this.sf_phone=false
				if(this.cishu==1){
					this.shangci()
				}
			} else {
				this.mobile = ''
				this.emptyUser()
			}
			this.qiandao()
			this.tzbk_list()
			this.mobile= hideMobile(uni.getStorageSync('mobile')) || ''
			this.name=uni.getStorageSync('userinfo').name
			this.address=uni.getStorageSync('address')
			// if(option){
			// 	this.daid=option.daid
			// 	this.id=option.id
			// }
			this.firstCome = false
		},
		onShow() {
			if (uni.getStorageSync('token')) {
				this.xiaoxi_num=uni.getStorageSync('xiaoxi_num')
			} else {
				uni.setStorageSync('xiaoxi_num', 0)
				this.xiaoxi_num = 0
			}
			this.isShowMobile = hideMobile(uni.getStorageSync('mobile')) || ''
			console.log('%c [ this.isShowMobile ]-350', 'font-size:13px; background:pink; color:#bf2c9f;', this.isShowMobile)
			this.mobile = uni.getStorageSync('mobile') || ''
			// permision.gotoAppPermissionSetting()
			// openAppSettingPermissions()
			// uni.openAppAuthorizeSetting({
			// 	success (res) {
			// 		console.log(res)
			// 	}
			// })
			// openAppSettingPermissions()

		},
		// onHide() {
		// 	this.cishu=0
		// },
		// onHide(){
		// 	uni.removeStorageSync('tzid')
		// },
		// onShow() {
		// 	this.tzbk_list()
		// 	if(uni.getStorageSync('fb_type')==1){
		// 		if(uni.getStorageSync('tzid')){
		// 			this.tzxq()
		// 		}

		// 	}else{
		// 		this.mobile = uni.getStorageSync('mobile')
		// 		this.name = uni.getStorageSync('userinfo').name
		// 		this.address = uni.getStorageSync('address')
		// 	}
		// 	this.fa_bu=false
		// 	this.longitude = uni.getStorageSync('longitude')
		// 	this.latitude = uni.getStorageSync('latitude')
		// 	console.log(this.daid,this.id)
		// 	if (uni.getStorageSync('token') == '' || uni.getStorageSync('token') == null) {
		// 		this.$refs.popup.open()
		// 		return
		// 	} else if (uni.getStorageSync('mobile') == null || uni.getStorageSync('mobile') == '') {
		// 		this.$refs.popup1.open()
		// 		return
		// 	} else {

		// 	}
		// },
		methods: {
			hideMobile,
			emptyUser() {
				this.mobile = ''
			},
			// 首页弹框图片
			tankuang: function() {
				this.post('api/index/showVipPoster', '', false).then(res => {
					console.log(res)
					if (res.code == 1) {
						if (res.data.status ==1) {
							this.tc_is_show = true
							this.tc_image = res.data.poster
						} else {
							this.tc_is_show = false
						}
					}
				})
			},

			// 优惠券
			bgtu_tiao: function() {
				this.tc_is_show = false
				if (uni.getStorageSync('token') == '' || uni.getStorageSync('token') == null) {
					this.$refs.popup.open()
					return
				}
				else {
					if (this.iosUpAppStore) {
						uni.navigateTo({
							url: '../../subpages/pages/vip'
						})
					}
				}

			},
			// 背景关闭
			bgguan: function() {
				this.tc_is_show = false
				uni.setStorageSync('tan_type','1')
			},
			shuju: function() {
				this.post1('api/chat', '',false).then(res => {
					console.log(res, 147)
					if (res.code == 1) {
						this.zuixin = res.data
					}
				})
			},
			jiage:function(){
				this.$refs['picker6'].show()
			},
			handleConfirm4 (e) {
			  // 如果存在多个picker，可以在picker上设置dataset属性，confirm中获取，就能区分是哪个picker了
			  console.log('confirm::', e)
			  if (e) {
			    // const name = e.dataset.name
			    this.label2 = e.item.map(m => m.label).join('-')
			    // if (name && label) {
			    //   this[name] = label
			    // }
			  }
			  this.province=e.item[0].label
			   this.city=e.item[1].label
			},
			dianji:function(index){
				console.log(index)
				// return
				if(this.id_list.length<=0){
					this.id_list.push(this.idfanwei_list[index])
					this.xuan_cp_list.push(this.chanpin_list[index].name)
				}else{
					for(let i=0;i<this.id_list.length;i++){
						if(this.id_list[i]==this.idfanwei_list[index]){
							return
						}
					}
					this.id_list.push(this.idfanwei_list[index])
					this.xuan_cp_list.push(this.chanpin_list[index].name)
				}

			},
			fangda:function(type){
				 uni.previewImage({
				        urls: this.addImgArray_arr,
				        current:type
				 });
			},
			fbrsf:function(){
				let that=this
				uni.showActionSheet({
					itemList: that.list,
					success: function (res) {
						console.log('选中了第' + (res.tapIndex + 1) + '个按钮');
						// let index = res.tapIndex
						that.city1 =  that.list[res.tapIndex]
					},
					fail: function (res) {
						console.log(res.errMsg);
					}
				});
			},

			// 上次发帖习惯
			shangci:function(){
				this.post('api/voice/pre_voice','',false).then(res=>{
					console.log(res,112233)
					this.chanpin_list=[]
					this.fenlei=''
					this.daid=''
					this.idfanwei_list=[]
					if(res.code==1){
						this.city=res.data.city
						this.province=res.data.province
						this.name=res.data.name
						// this.mobile=res.data.mobile
						if(res.data.province=='' || res.data.province==undefined){
							this.label2=''
						}else{
							this.label2 =res.data.province+'-'+res.data.city
						}
						this.fenlei=res?.data?.category?.name
						this.daid=res?.data?.category?.id
						this.idfanwei_list=res?.data?.voice_manage_id?.split(',')
						if (this.idfanwei_list?.length) {
							for(let i=0;i<res.data.manage_data.length;i++){
								if(res.data.manage_data[i].two==''){
									this.chanpin_list.push(
										{
											name:res.data.manage_data[i].one,
											check:false
										}
									)
								}else if(res.data.manage_data[i].three==''){
									this.chanpin_list.push(
										{
											name:res.data.manage_data[i].one+'-'+res.data.manage_data[i].two,
											check:false
										}
									)
								}else{
									this.chanpin_list.push(
										{
											name:res.data.manage_data[i].one+'-'+res.data.manage_data[i].two+'-'+res.data.manage_data[i].three,
											check:false
										}
									)
								}
							}
						}
						this.zidingyi=res.data.search_field || ''
					}
				})
			},
			getPostcategory(){
				let daid_list
				if(this.daid.length>1){
					daid_list=this.daid.split(',')
				}else{
					daid_list=this.daid
				}

				this.post('api/voice/voice_category',{voice_manage_id:this.voice_manage_id},true).then(res=>{
					console.log(res)
					if(res.code==1){
						this.one_list=res.data
						for(let i=0;i<res.data.length;i++){
							for(let j=0;j<res.data[i].category_list.length;j++){
								if(this.daid.length<=1){
									console.log(11111111111)
									if(daid_list==res.data[i].category_list[j].id){
										this.one_list[i].category_list[j].check=true
									}
								}else{
									console.log(222222222222)
									for(let m=0;m<daid_list.length;m++){
										if(daid_list[m]==res.data[i].category_list[j].id){
											this.one_list[i].category_list[j].check=true
										}
									}
								}
							}
						}
						// console.log(this.type)
						// console.log(res.data[this.type])
						// this.one_list=res.data[this.type]
					}
				})
			},
			// 获取用户信息
			async user_info() {
				let isLogin = await this.$refs.noLoginToast.open()
				if (isLogin) {
					this.post('api/client/info', '', true).then(res => {
						console.log(res)
						if(res.code==1){
							if(res.data.firm_id!=''){
								this.list=['个人', '企业']
							}else{
								this.list=['个人']
							}
							this.degree=res.data.degree
							if(this.degree<100){
								this.$refs.model.open()
							}else{

							}
							// this.mobile = hideMobile(res.data.mobile) || ''
							this.chat_look=res.data.chat_look
						}else if(res.code==401){
							uni.removeStorageSync('token')
							uni.removeStorageSync('userinfo')
							uni.removeStorageSync('mobile')
							this.$refs.popup.open()
						}
					})
				}
			},
			// 帖子板块
			tzbk:function(name){
				this.$refs[name].show()
			},
			// 帖子板块列表
			tzbk_list:function(){
				this.post('api/voice/special_type','',false).then(res=>{
					console.log(res)
					if(res.code==1){
						this.yuan_list3=res.data
						for(let i=0;i<res.data.length;i++){
							this.list3.push(res.data[i].title)
						}
					}
				})
			},
			handleConfirm3(e) {
				console.log(e)
				let index = e.index[0] || e.index
				this.bankuai = e.value
				this.bankuai_id=this.yuan_list3[index].id
			},
			// 选择分类
			xzfl:function(){
				if(this.id_list==''){
					uni.showToast({
						title: '请先选择产品分类',
						duration: 2000,
						icon: "none"
					})
					return
				}else{
					console.log('%c [ this.id_list ]-629', 'font-size:13px; background:pink; color:#bf2c9f;', this.id_list)
					uni.navigateTo({
						url:'../index/fabu?type='+0+'&daid='+this.daid+'&fanwei_id='+this.id_list
					})
				}

			},
			async xzcpfl(){
				// if(this.daid==''){
				// 	uni.showToast({
				// 		title: '请先选择帖子分类',
				// 		duration: 2000,
				// 		icon: "none"
				// 	})
				// }else{
				// 	uni.navigateTo({
				// 		url:'../index/fabu1?type='+1+'&id='+this.daid+'&fanwei_id='+this.id_list+'&fanwei_list='+this.chanpin_list+'&zidingyi='+this.zidingyi
				// 	})
				// }
				let isLogin = await this.$refs.noLoginToast.open()
				if (!isLogin) {
					return
				}
				uni.navigateTo({
					url:'../index/fabu1?type='+1+'&id='+this.daid+'&fanwei_id='+this.id_list+'&fanwei_list='+JSON.stringify(this.xuan_cp_list)+'&zidingyi='+this.zidingyi
				})
				// +'&lishi_list='+JSON.stringify(this.chanpin_list)
			},
			kaiqi:function(){
				let that=this
				uni.getSystemInfo({
				    success: function (res) {
				        console.log(res.model);
						let str = res.model
						console.log(str.indexOf("iPhone") != -1); // true
						that.post('api/post/isIosTop','',true).then(re=>{
							console.log(re)
							if(str.indexOf("iPhone") != -1){
								if(re.data==1){
									that.xian=true
								}else{
									that.xian=false
								}
							}else{
								that.xian=true
							}
						})

				    }
				});
			},
			zhiding: function() {
				this.post('api/post/post_top', '', true).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.zd_list = res.data
					}
				})
			},
			zd_xz: function(index) {
				this.zd_type = index
			},
			// quxiao2: function() {
			// 	this.$refs.popup2.close()
			// 	this.pl_xs = 2
			// },
			// guanbi2: function() {
			// 	this.$refs.popup2.close()
			// 	this.$refs.popup3.open()
			// },
			// zdzf: function(index) {
			// 	this.zd_status = index + 1
			// },
			// quxiao3: function() {
			// 	this.$refs.popup3.close()
			// 	this.pl_xs = 2
			// },
			// guanbi3: function() {
			// 	this.$refs.popup3.close()
			// },
			// 浅到规则
			qiandao: function() {
				this.post('api/index/site', '', false).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.rule = res.data.fbxz
					}
				})
			},
			fbxz: function() {
				uni.navigateTo({
					url:'/subpages/pages/rzxz?type='+1
				})
				return
				this.$refs.popup2.open()
			},
			guan: function() {
				this.$refs.popup2.close()
			},
			handleTap(name) {
				this.$refs[name].show()
			},
			handleConfirm(e) {
				console.log(e)
				let index = e.index[0] || e.index
				this.city1 = e.value
			},
			// 获取位置
			address_xx: function(index) {
				let that = this
				uni.authorize({
					scope: 'scope.userLocation',
					success() { //1.1 允许授权
						that.hqxxdd()
					},
					fail() { //1.2 拒绝授权
						uni.showModal({
							content: '检测到您没打开获取信息功能权限，是否去设置打开？',
							confirmText: "确认",
							cancelText: '取消',
							success: (res) => {
								if (res.confirm) {
									uni.openSetting({
										success: (res) => {
											console.log(res);
											that.hqxxdd()
										}
									})
								} else {
									console.log('取消');
									return false;
								}
							}
						})
						return false;
					}
				})
			},
			// 获取详细地址
			hqxxdd: function(e) {
				let that = this
				uni.chooseLocation({
					success: function(res) {
						console.log('位置名称：' + res.name);
						console.log('详细地址：' + res.address);
						console.log('纬度：' + res.latitude);
						console.log('经度：' + res.longitude);
						that.address = res.address
						that.longitude = res.longitude
						that.latitude = res.latitude
						qqmap.reverseGeocoder({
							location: {
								latitude: res.latitude,
								longitude: res.longitude
							},
							success: function(re) {
								console.log(re,111111111)
								that.province = re.result.address_component.province
								that.city = re.result.address_component.city
								uni.setStorageSync('address', re.result.address)
								that.area = re.result.address_component.district; // 区
							},
							fail: function(res) {
								uni.showToast({
									title: '定位失败',
									duration: 2000,
									icon: "none"
								})
								console.log(res);
							},
							complete: function(res) {

							}
						})
						// that.city=res.address
					}
				});
			},
			back: function() {
				uni.navigateBack({
					delta: 1
				})
			},
			// 上传图片
			async chooseImage() {
				let isLogin = await this.$refs.noLoginToast.open()
				if (!isLogin) {
					return
				}
				// let stutas = await requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
				// openAppSettingPermissions()
				// console.log('%c [ stutas ]-862', 'font-size:13px; background:pink; color:#bf2c9f;', stutas)
				let that = this
				if (that.addImgArray_arr.length >= 9) {
					uni.showToast({
						icon: 'none',
						title: '最多上传9张图片'
					})
					return
				}
				try {
					this.$refs.uploadImg.open()
				} catch (error) {
					uni.hideLoading()
				}
			},
			// 删除图片
			imgdelete(index) {
				// this.addimgArray.splice(index, 1)
				this.addImgArray_arr.splice(index, 1)
				// this.addimgArray.splice(index, 1)
			},
			//是否制定、、置顶
			plxs_switch1Change: function(e) {
				if (e.target.value) {
					this.pl_xs = 1
					this.$refs.popup2.open()
				} else {
					this.pl_xs = 2
				}
			},
			//设为默认
			ismoren() {
				this.default1 = !this.default1
				console.log('%c [ this.default1 ]-925', 'font-size:13px; background:pink; color:#bf2c9f;', this.default1)
			},
			checkboxChange(val) {
				this.default1 = val
			},
			tzxq: function(id) {
				this.post('api/voice/info', {
					id:uni.getStorageSync('tzid')
				}, true).then(res => {
					if (res.code == 1) {
						this.content=res.data.main_content
						this.addImgArray_arr = res.data.main_images
						// this.mobile = res.data.mobile
						this.name =  res.data.name
						// this.address = res.data.address
						if(res.data.type==2){
							this.city1=='个人'
						}else{
							this.city1=='企业'
						}
						this.bankuai_id=res.data.special_type
						this.bankuai=res.data.special_type_text
						this.city=res.data.city
						this.province=res.data.province
						this.area=res.data.district
						this.fenlei=res.data.category.name
						this.daid=res.data.category.id
						// this.chanpin=res.data.manage_data.one+'-'+
						// 			res.data.manage_data.two+'-'+
						// 			res.data.manage_data.three
						// this.id=res.data.voice_manage_id
						uni.removeStorageSync('tzid')
						// this.id = res.data.category_id
						// this.content = res.data.content
						// this.addImgArray_arr = res.data.images
						// this.name = res.data.name
						// this.mobile = res.data.mobile
						// this.address = res.data.address
						// this.longitude = res.data.longitude
						// this.latitude = res.data.latitude
						// this.city = res.data.region
						// this.num = res.data.number
						// this.yemc = res.data.company_name
						// this.zpzw = res.data.position_name
						// this.szhy = res.data.industry_name
						// this.did=res.data.pid
					}
				})
			},

			// 获取验证码
			huoqu: function() {
				if (this.mobile == '') {
					uni.showToast({
						title: '请获取手机号',
						icon: "none",
						duration: 1000
					})
					return
				} else if (!(/^1[3456789]\d{9}$/.test(this.mobile))) {
					uni.showToast({
						title: '请输入正确的手机号',
						icon: "none",
						duration: 1000
					})
					return
				} else {
					this.post('api/voice/mobile_change_code', {
						mobile: this.mobile
					}, true).then(res => {

						if (res.code == 1) {
							uni.showToast({
								title: res.msg,
								icon: "none",
								duration: 1000
							})
							this.validateBtn()
						} else {
							uni.showToast({
								title: res.msg,
								icon: "none",
								duration: 1000
							})
						}
					})
				}

			},

			// 倒计时
			validateBtn() {
				//倒计时
				let time = 120;
				let timer = setInterval(() => {
					if (time == 0) {
						clearInterval(timer);
						this.disabled = false;
						this.btnTitle = "获取验证码";
					} else {
						this.btnTitle = time + '秒后重试';
						this.disabled = true;
						time--
					}
				}, 1000)
			},
			async queren() {
				let isLogin = await this.$refs.noLoginToast.open()
				console.log('%c [ isLogin ]-1037', 'font-size:13px; background:pink; color:#bf2c9f;', isLogin)
				if (isLogin) {
					let isHasMobile = await this.$refs.noLoginToast.getPhoneNumber()
					console.log('%c [ isHasMobile ]-452', 'font-size:13px; background:pink; color:#bf2c9f;', isHasMobile)
					if (!isHasMobile) {
						return
					}
				} else {
					return
				}
				console.log('%c [ this.default1 ]-996', 'font-size:13px; background:pink; color:#bf2c9f;', this.default1)
				let that=this
				let reg =/^1[3456789]\d{9}$/;
				if(!this.default1){
					uni.showToast({
						title:'请同意发布须知',
						icon: "none",
						duration: 1000
					})
					return
				}else if(!reg.test(this.mobile)){
					uni.showToast({
						title:'请输入手机号码',
						icon: "none",
						duration: 1000
					})
					return
				}else if(this.sf_phone){
					if(this.code==''){
						uni.showToast({
							title:'请输入验证码',
							icon: "none",
							duration: 1000
						})
						return
					}else if(!(/^[0-9]*$/.test(this.code))){
						uni.showToast({
							title:'请输入正确的验证码',
							icon: "none",
							duration: 1000
						})
						return
					}
				}
				that.qiu()
				return
					if(this.sf_phone){
						this.post('api/voice/check_mobile_change',{mobile:this.mobile,code:this.code},true).then(res=>{
							if(res.code==1){
								that.qiu()
							}else{
								uni.showToast({
									title: res.msg,
									duration: 1000,
									icon: 'none'
								});
							}
						})
					}else{
						this.qiu()
					}
			},
			qiu:function(){
				let that=this
				let a=''
				if(this.city1=='个人'){
					a=2
				}else{
					a=1
				}
				let data = {
					voice_category_id: that.daid,
					voice_manage_id:that.id_list.join(',') || that.zixuan_id.join(','),
					main_content: that.content,
					main_images: that.addImgArray_arr.join(','),
					// name: that.name,
					mobile: that.mobile,
					type:a,
					address:that.address,
					longitude:that.longitude,
					latitude:that.latitude,
					// special_type:that.bankuai_id,
					city:this.city,
					province:this.province,
					// district:this.area
					code:that.code,
					search_field:that.zidingyi,
					show_mobile:that.gun_code?1:0,
					// address: this.address,
					// longitude: this.longitude,
					// latitude: this.latitude,
					// region: this.city,
					// number: this.num,
					// company_name: this.yemc,
					// position_name: this.zpzw,
					// industry_name: this.szhy,
					// trade_type: this.zd_status,
					// top_id: this.zd_list[this.zd_type].id,
					// event: 'check'
				}
				console.log('%c [ data ]-1084', 'font-size:13px; background:pink; color:#bf2c9f;', data)
				// return
				that.fa_bu=true
				that.post('api/voice/publish', data, true).then(res => {
					console.log(res)
					if (res.code == 1) {
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
						uni.removeStorageSync('fb_type')
						that.mobile=uni.getStorageSync('userinfo').mobile
						that.name=uni.getStorageSync('userinfo').name
						that.address=uni.getStorageSync('address')
						that.sf_phone=false
						that.daid=''
						that.id=''
						that.content=''
						that.addImgArray_arr=[]
						that.bankuai_id=''
						that.fa_bu=false
						that.fenlei=''
						that.chanpin=''
						that.bankuai=''
						that.id_list=[]
						that.idfanwei_list=[]
						that.chanpin_list=[]
						that.xuan_cp_list=[]
						that.zidingyi=''
						that.cishu=0
						setTimeout(function(){
							uni.switchTab({
								url:'/pages/index/index'
							})
						},1500)
					}else if(res.code==201){
						that.post('api/pay/voice_pay',{voice_id:res.data.voice_id},true).then(pays=>{
							console.log(pays)
							if(pays.code==1){
								uni.getSystemInfo({
								    success: function (res) {
										let str = res.model
										console.log(str.indexOf("iPhone") != -1); // true
										that.post('api/index/wechat_check','',true).then(re=>{
											if(str.indexOf("iPhone") != -1){
												if(re.data==1){
													that.fukuan()
												}else{
													uni.showModal({
													    title: '温馨提示',
													    content: '由于相关规范，ios功能暂不可用！',
													    success: function (res) {
													        if (res.confirm) {

													        } else if (res.cancel) {

													        }
													    }
													});

												}
											}else{
												that.fukuan()
											}
										})

								    }
								});
							}else{
								that.fa_bu=false
								uni.showToast({
									title: res.msg,
									duration: 1000,
									icon: 'none'
								});
							}
						})
					}else if(res.code==206){
						if(res.data.is_vip==2){
							uni.showModal({
								title: '提示',
								content: res.data.msg,
								success: function (res1) {
									if (res1.confirm) {
										if (that.iosUpAppStore) {
											uni.navigateTo({
												url: '../../subpages/pages/vip'
											})
										}
									} else if (res1.cancel) {

									}
								}
							});
						}else if(res.data.is_vip==0){
							uni.showModal({
								title: '提示',
								content: res.data.msg,
								success: function (res1) {
									if (res1.confirm) {
										if (that.iosUpAppStore) {
											uni.navigateTo({
												url: '../../subpages/pages/vip'
											})
										}
									} else if (res1.cancel) {

									}
								}
							});
						}
					}
					else {
						that.fa_bu=false
						uni.showToast({
							title: res.msg,
							duration: 1000,
							icon: 'none'
						});
					}
				})
			},
			fukuan:function(){
				let that=this
				uni.requestPayment({
					    provider: 'wxpay',
					    timeStamp: pays.data.timeStamp,
					    nonceStr: pays.data.nonceStr,
					    package: pays.data.package,
					    signType: pays.data.signType,
					    paySign: pays.data.paySign,
					    success: function (res) {
					      uni.showToast({
					      	title: '支付成功',
					      	icon: "none",
					      	duration: 1000
					      })
						  uni.removeStorageSync('fb_type')
							that.mobile=uni.getStorageSync('userinfo').mobile
							that.name=uni.getStorageSync('userinfo').name
							that.address=uni.getStorageSync('address')
						  that.sf_phone=false
						  that.daid=''
						  that.id=''
						  that.content=''
						  that.addImgArray_arr=[]
						  that.bankuai_id=''
						  that.fa_bu=false
						  that.fenlei=''
						  that.chanpin=''
						  that.bankuai=''
						  that.id_list=[]
						  that.idfanwei_list=[]
						  that.chanpin_list=[]
						  that.xuan_cp_list=[]
						  that.zidingyi=''
						  that.cishu=0
						  setTimeout(function(){
						  	uni.switchTab({
						  		url:'/pages/index/index'
						  	})
						  },1500)
					    },

					    fail: function (err) {
							that.fa_bu=false
							uni.showToast({
								title: '您已取消支付',
								icon: "none",
								duration: 1000
							})
					        console.log(err);
					    }
				});
			},
			quxiao: function() {
				this.$refs.popup.close()
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			quxiao1: function() {
				this.$refs.popup1.close()
				uni.switchTab({
					url:'/pages/index/index'
				})
			},
			login1: function(e) {
				console.log(e)
				let that = this
				this.$refs.popup1.close()
				uni.login({
					provider: 'weixin',
					success: (code) => {
						console.log(code)
						this.post('api/wechat/phone', {
							code: code.code,
							iv: e.detail.iv,
							encryptedData: e.detail.encryptedData
						}, true).then(res => {
							console.log(res, '123455')
							if (res.code == 1) {
								uni.setStorageSync('mobile', res.data.phoneNumber)
								that.mobile=res.data.phoneNumber
								uni.setStorageSync('mobile2',res.data.mobile2)
								that.user()
								that.shangci()
								that.tankuang()
							}else{
								uni.showToast({
									title: res.msg,
									icon: "none",
									duration: 1000
								})
							}

						})

					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.active{
		color: #fff;
		background-color: #1FB0AC;
	}
	.as{
		color: #333333;
		background-color: #F3F3F3;
	}
	.moren {
		display: flex;
		align-items: center;
		margin-top: 28rpx;
		text {
			font-size: 26upx;
			color: #666666;
		}

	}

	page {
		background-color: #F8F8F8 !important;
		font-family: Demibold;
		// padding-bottom:180rpx!important;
	}

	.slot-wrap {
		display: flex;
		align-items: center;
		/* 如果您想让slot内容占满整个导航栏的宽度 */
		/* flex: 1; */
		/* 如果您想让slot内容与导航栏左右有空隙 */
		padding: 0 30rpx;
	}

	.maincontent {
		width: 92%;
		margin: 0 auto;
		padding: 20rpx 30rpx 36rpx;
		box-sizing: border-box;
		background-color: #FFFFFF;
		border-radius: 20rpx;

		.input {
			height: 100upx;
			width: 100%;
			box-sizing: border-box;
			padding: 30rpx 0;
			// margin-left: 40upx;
			border-bottom: 2upx solid #f0f0f0;
			display: flex;
			align-items: center;

			text {
				font-size: 28rpx;
				color: #262D2C;

			}

			input {
				flex: 1;
				font-size: 28rpx;
				color: #262D2C;
			}
		}
		.input1{
			height: 100upx;
			width: 100%;
			box-sizing: border-box;
			padding: 30rpx 0;
			// margin-left: 40upx;

			display: flex;
			align-items: center;
			text{
				font-size: 28rpx;
				color: #262D2C;

			}
			input{
				flex: 1;
				font-size: 28rpx;
				color: #262D2C;
			}
		}
	}
	.actives1{
		border-bottom: 2upx solid #f0f0f0;
	}
	.as1{
		border-bottom: none;
	}
	// 上传图片
	.upload {
		// background: #FFFFFF;
		// padding: 0 40rpx;
		// height: 100vh;
		// height: 700upx;

		.title {
			font-size: 30rpx;
			font-weight: bold;
			color: #343434;
			padding-top: 15rpx;
		}

		.uploadimgcont {
			display: flex;
			// justify-content: space-between;
			flex-wrap: wrap;
			// margin-top: 50rpx;
			// margin:30upx 0 136upx;

			.uploadimga {
				width: 186rpx;
				height: 186rpx;
				margin-right: 24upx;
				margin-bottom: 40upx;
				position: relative;

				.delete {
					width: 40rpx;
					height: 40rpx;
					border-radius: 50%;
					background: #5093ff;
					display: flex;
					align-items: center;
					justify-content: space-around;
					position: absolute;
					top: -10upx;
					left: -10upx;
					z-index: 4;

					.deleteline {
						background: #FFFFFF;
						height: 5rpx;
						width: 50%;
					}
				}

				image {
					width: 100%;
					height: 100%;
				}
			}

			.uploadimg {
				width: 120rpx;
				height: 120rpx;
				background: #F9F9F9;
				border-radius: 120rpx;
				// overflow: hidden;
				position: relative;

				image {
					width: 100%;
					height: 100%;
				}

				view {
					position: absolute;
					bottom: 10rpx;
					left: 50%;
					width: 100%;
					text-align: center;
					transform: translateX(-50%);
					font-size: 28rpx;
					color: #404040;
				}
			}
		}

	}
	.footer {
		display: flex;
		justify-content: space-between;
		border-top: 1px solid #f4f4f4;
		margin-top: 30rpx;
		padding-bottom: 20rpx;

		button {
			margin: 0 auto;
			width: 100%;
			background-color: #19BE6B;
			// width: 200upx;
			border-radius: 10upx;
			font-size: $uni-font-size-sm;
			// padding: 22upx 34upx;
			height: 80upx;
			font-size: 30rpx;
			line-height: 80upx !important;
			// line-height: 1;
			color: #FFFFFF;
		}

		button:after {
			border: 0;
		}
	}
	.shou {
		margin: 0 auto;
		width: 160rpx;
		// width: 200upx;
		border-radius: 30rpx;
		font-size: $uni-font-size-sm;
		// padding: 22upx 34upx;
		height: 60upx;
		font-size: 28rpx;
		line-height: 60upx !important;
		// line-height: 1;
		color: #FFFFFF;
		padding: 0;
		font-size: 26rpx;
	}

	.shou:after {
		border: 0;
	}
</style>
